﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameLibrary.Unit
{
    using Interfaces;
    using Events;
    using System.Xml.Linq;
    [Serializable]
    public class Unit : AbstractMapObject,
                        IUnit
    {
        #region variables

        #region template

        public Template Template { get; private set; }

        /// <summary>
        /// Upgrade
        /// </summary>
        /// <param name="t"></param>
        public void UpgradeUnit(Template t)
        {
            this.Template = t;
            this.Current.Reset(this.Template);
            this.Current.AP = 0;
        }

        #endregion

        #region current

        public CurrentAbility Current { get;internal set; }

        #endregion

        #region info

        public UnitInfo Info { get { return new UnitInfo(this); } }

        #endregion

        #endregion

        #region constructor

        public Unit(Position position, uint ownerID, Template template)
            : base(position, ownerID)
        {
            this.Template = template;
            this.Current = new CurrentAbility(this.Template);
        }

        #endregion

        #region get cost

        public uint GetCost()
        {
            return this.Template.Cost;
        }

        #endregion

        #region next turn

        public void NextTurn()
        {
            this.Current.Reset(this.Template);
        }

        #endregion
    }
}
